package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type AddConfig struct {
	Mysql struct {
		Host     string
		Port     int
		User     string
		Password string
		Database string
	}
	Redis struct {
		Host     string
		Port     int
		Password string
		Database int
	}
}

var Config AddConfig

func Init() {
	viper.SetConfigFile("../appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("动态配置读取失败")
	}

	if err = viper.Unmarshal(&Config); err != nil {
		fmt.Println("动态配置解析失败")
	}
	fmt.Println("动态配置加载成功", Config)
}
